#!/usr/bin/perl
#
# Test harness for routines of the machine registration script
#
#
$IsInTestHarness = 1;

require "machine-update";

print "Test harness ready\n";

# Set options as for the script.
# Some don't make sense...
options();

$action = shift;
$data = shift;
if ($action eq "cpu") {
    while ($data) {
	$cpufile = $data;
	print "From Test\@harness\n";
	print "CPUFilename: $data\n";
	print "\n//MACHINE\n";
	# Force some values in order to make CPU script behave
	$values{method} = "machine-update version $VERSION";
	$values{kernel} = "2.4.4-harness";
	cpuinfo();
	dumpdata();
	print "//END\n";
	$data = shift;
    }
} else {
    die "ERROR: Unknown command $action\n";
}


sub dumpdata {
    for $key (keys(%values)) {
	print "$key:$values{$key}\n";
    }
    if ($debugdata) {
	print "==== Debug data:\n";
	print $debugdata;
    }
    if ($errordata) {
	print "==== Error data:\n";
	print $errordata;
    }
    undef %values;
    undef $debugdata;
    undef $errordata;
}
